function initOption()
    {
    	var search=window.location.search;
    	if((index=search.indexOf('day='))!=-1)
    	{
        	last=search.indexOf('&',index+1);
        	if(last==-1)
            	day=search.slice(index+4);
        	else
            	day=search.slice(index+4,last);

        	if(day !='3' && day !='7' && day !='15' &&day !='30')
    			document.getElementById('day-7').selected=true;
        	else 
            	document.getElementById('day-'+day).selected=true;
        }
    	else
    	{
        	document.getElementById('day-15').selected=true;
       	}
    }

    function display_selected_activity(days)
    {
        var search=window.location.search;
        if((index=search.indexOf('day='))!=-1)
        {
            search=search.replace(/day=.*[^&]/,"day="+days);
            window.location.search=search;
        }
        else
        {
        	window.location.search=search+'&day='+days;
        }	

    }
    
    function clear_message(user_id,clear_type)
    {
        var r=confirm('您真的要清除这些信息吗？');
        if(r==false)
            return false;
    	var url=BASE_HOSTPATH+"/dr-includes/dr-ajax-clear-record.php";
    	var xmlhttp=false;
    	if(window.ActiveXObject)
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	else if(window.XMLHttpRequest)
    		xmlhttp=new XMLHttpRequest();
    	if(!xmlhttp)
    	{
    		alert("不能创建XMLHTTP实例");
    		return false;
    	}

    	xmlhttp.open("POST",url,true);
    	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    	xmlhttp.onreadystatechange=function()
    	{
    		if(xmlhttp.readyState==4)
    		{
    			var msg=xmlhttp.responseText;
    			if(msg==1)
    			{
        			if(clear_type=="message")
        			{
	    				document.getElementById('message_info').innerHTML="新消息已被清除！";
	    				document.getElementById('message_list').innerHTML="";
        			}
        			else if(clear_type=="action")
        			{
        				document.getElementById('message_info').innerHTML="活动记录已被清除！";
	    				document.getElementById('activity_list').innerHTML="";
            		}
    			}
    			else if(msg==0)
    			{
    				//alert(msg);
    			}
    			else 
        			alert(msg);
    				
    		}
    	}

    	result="user_id="+user_id+"&clear_type="+clear_type;
    	result+="&nocache="+new Date().getTime();
    	xmlhttp.send(result);
    }
    
    function mark_question(question_id,is_login,value)
    {
    	
    	if(!is_login)
    	{
    		comment_answer(0,question_id,is_login);
    		return false;
    	}
    	
    	var mark_type;
    	if(value=='关注')
    		mark_type='mark';
    	else if(value=='取消关注')
    		mark_type='cancel_mark';
    	
    	var url=BASE_HOSTPATH+"/dr-includes/dr-ajax-mark-question.php";
    	var xmlhttp=false;
    	if(window.ActiveXObject)
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	else if(window.XMLHttpRequest)
    		xmlhttp=new XMLHttpRequest();
    	if(!xmlhttp)
    	{
    		alert("不能创建XMLHTTP实例");
    		return false;
    	}

    	xmlhttp.open("POST",url,true);
    	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    	xmlhttp.onreadystatechange=function()
    	{
    		if(xmlhttp.readyState==4)
    		{
    			var msg=xmlhttp.responseText;
    			//alert(msg);
    			if(msg==1)
    			{
    				//alert(msg);
    				//document.getElementById("mark-"+question_id).disabled=true;
    				if(mark_type=='mark')
    					document.getElementById("mark-"+question_id).value='取消关注';
    				else if(mark_type=='cancel_mark')
    					document.getElementById("mark-"+question_id).value='关注';
    				
    			}
    			else if(msg==0)
    			{
    				//alert(msg);
    			}
    			else 
        			alert(msg);
    				
    		}
    	}

    	result="qid="+question_id+"&mark_type="+mark_type;
    	result+="&nocache="+new Date().getTime();
    	//alert(result);
    	xmlhttp.send(result);
    }

    
    function mark_user(marked_user_id,type,is_login)
    {
    	if(!is_login)
        	return false;
    	
        if(type=='收听')
            type='mark';
        else if(type=='取消收听')
            type='cancel_mark';
        
    	var url=BASE_HOSTPATH+"/dr-includes/dr-ajax-mark-user.php";
    	var xmlhttp=false;
    	if(window.ActiveXObject)
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	else if(window.XMLHttpRequest)
    		xmlhttp=new XMLHttpRequest();
    	if(!xmlhttp)
    	{
    		alert("不能创建XMLHTTP实例");
    		return false;
    	}

    	xmlhttp.open("POST",url,true);
    	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    	xmlhttp.onreadystatechange=function()
    	{
    		if(xmlhttp.readyState==4)
    		{
    			var msg=xmlhttp.responseText;
    			if(msg==1)
    			{
        			
    				if(type=='mark')
    			    {	
    					var sig1=document.getElementById('userlistened-'+marked_user_id);
    			        var sig2=document.getElementById('userlistening-'+marked_user_id);
    			        
    			        if(sig1!=null)
        			        sig1.value='取消收听';
    			        if(sig2!=null)
        			        sig2.value='取消收听';
    			        
    			    }
    			    else if(type=='cancel_mark')
    			    {
    			    	 var sig1=document.getElementById('userlistened-'+marked_user_id);
    			         var sig2=document.getElementById('userlistening-'+marked_user_id);
    			         
    			         if(sig1!=null)
         			        sig1.value='收听';
     			        if(sig2!=null)
         			        sig2.value='收听';
    			         
    			    }
        		}
    			else
        			alert(msg);
    			
    		}
    	}

    	result="marked_user_id="+marked_user_id+"&mark_type="+type;
    	result+="&nocache="+new Date().getTime();
    	//alert(result);
    	xmlhttp.send(result);
    }

    function mark_tag(marked_tag_id,type,is_login)
    {
    	if(!is_login)
        	return false;
    	
        if(type=='关注')
            type='mark';
        else if(type=='取消关注')
            type='cancel_mark';
        
    	var url=BASE_HOSTPATH+"/dr-includes/dr-ajax-mark-tag.php";
    	var xmlhttp=false;
    	if(window.ActiveXObject)
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	else if(window.XMLHttpRequest)
    		xmlhttp=new XMLHttpRequest();
    	if(!xmlhttp)
    	{
    		alert("不能创建XMLHTTP实例");
    		return false;
    	}

    	xmlhttp.open("POST",url,true);
    	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    	xmlhttp.onreadystatechange=function()
    	{
    		if(xmlhttp.readyState==4)
    		{
    			var msg=xmlhttp.responseText;
    			if(msg==1)
    			{
    				if(type=='mark')
    			    {
    			        document.getElementById('tag-'+marked_tag_id).value='取消关注';
    			    }
    			    else if(type=='cancel_mark')
    			    {
    			         document.getElementById('tag-'+marked_tag_id).value='关注';
    			    }
        		}
    			else
        			alert(msg);
    			
    		}
    	}

    	result="marked_tag_id="+marked_tag_id+"&mark_type="+type;
    	result+="&nocache="+new Date().getTime();
    	//alert(result);
    	xmlhttp.send(result);
    }